//search模块下的vuex
import { GetSearchList } from '@/api'


const state = { //存储数据
    searchList: {},
}

const mutations = { //唯一修改state中的数据，方法名大写

    SEARCH_LIST(state, searchList) {
        state.searchList = searchList;
    },
}

const actions = { //方法的中转，然后调用mutations中的方法

    async getSearchList({ commit }, params = {}) {
        let result = await GetSearchList(params);
        if (result.code == 200) {
            commit('SEARCH_LIST', result.data)
        }
    },

}

const getters = { //相当于计算属性
    attrsList(state) {
        return state.searchList.attrsList || [];
    },
    goodsList(state) {
        return state.searchList.goodsList || [];
    },
    trademarkList(state) {
        return state.searchList.trademarkList || [];
    },
}

export default { state, mutations, actions, getters }